home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16825 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: news.erl.sbs.de!news
  2. From: Gerolf Wendland <wendland%hpp015%hpp001.mch2.scn.de@scn.de>
  3. Newsgroups: comp.lang.c++,comp.lang.c,comp.os.ms-windows.programmer.misc
  4. Subject: Re: fastest code
  5. Date: Fri, 12 Apr 1996 10:11:35 +0200
  6. Organization: Siemens Business Services
  7. Message-ID: <316E1037.41C67EA6@scn.de>
  8. References: <316112A2.7D37@public.sta.net.cn> <4kgbmj$j3j@solutions.solon.com> <4kghs7$250@news1.mnsinc.com> <4kgu7g$n9a@solutions.solon.com> <4kjc9n$f7j@samba.rahul.net>
  9. NNTP-Posting-Host: 139.3.107.122
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=iso-8859-2
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.01 (X11; I; SunOS 4.1.3 sun4m)
  14.  
  15. Whoever started this, he wrote:
  16. > >>: >>           for (i=0; i<16; i++)
  17. > >>: >>                   prom[i] = prom[i+i];
  18. > >
  19. > >>: HUH?  the code as written has a clear effect, which is to shove all of
  20. > >>: the elements of an array over one.  It certainly is an optimizer bug.
  21.                                                              ^^^^^^^^^^^^^^
  22. Really?
  23.  
  24. Richard Krehbiel:
  25. >In fact, I wrote exactly this loop once whose purpose was to initialize the
  26. >parity bits in memory, but be non-destructive in case it was just a
  27. >restart and not a power-on.
  28.  
  29. This seems to indicate that prom[i] are assigned a values that are never used.
  30. Maybe the optimizer has seen this. It should have issued a warning, which (the
  31. issueing) may have been prevented by not prom being the variable but by the 
  32. somewhat anonymous locations prom[i] being the variables in question. The optimizer 
  33. would have been even better if it had seen the fact that the loop is superflouos 
  34. and had removed it as well.
  35.  
  36. The volatile keyword is surely a good way to circumvent this problem.
  37.  
  38. Gerolf Wendland
  39.